package com.wbdgj.ui.mine;

import android.content.Context;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;

import com.google.gson.internal.LinkedTreeMap;
import com.igexin.sdk.PushManager;
import com.wbdgj.R;
import com.wbdgj.adapter.YhqAdapter;
import com.wbdgj.adapter.YhqMyAdapter;
import com.wbdgj.base.BaseActivity;
import com.wbdgj.base.BaseApplication;
import com.wbdgj.http.HttpAdapter;
import com.wbdgj.http.OnNoResponseListener;
import com.wbdgj.http.OnResponseListener;
import com.wbdgj.model.ResultObjectModel;
import com.wbdgj.ui.home.WbDetail01Fragment;
import com.wbdgj.ui.home.WbDetail02Fragment;
import com.wbdgj.ui.home.WbDetail03Fragment;
import com.wbdgj.ui.home.WbDetail04Fragment;
import com.wbdgj.ui.home.WbDetailActivity;
import com.wbdgj.ui.home.YhqDetailActivity;
import com.wbdgj.ui.home.YhqDetailMyActivity;
import com.wbdgj.ui.login.LoginActivity;
import com.wbdgj.utils.SpKeyUtils;
import com.wbdgj.utils.ToastUtils;
import com.wbdgj.utils.refresh.PullListView;
import com.wbdgj.utils.refresh.PullToRefreshLayout;
import com.wbdgj.views.NoScrollViewPager;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import retrofit2.Call;

/**
 * Created by Administrator on 2018/6/1.
 */

public class YhjActivity extends BaseActivity{

    private Context context = this;

    private static TabLayout mTabLayout;
    @BindView(R.id.destination_viewpager)
    ViewPager mViewPager;

    private MyFragmentPagerAdapter adapter;
    private List<Fragment> fragments;
    private Coupon01Fragment Coupon01Fragment;
    private Coupon02Fragment Coupon02Fragment;
    private Coupon03Fragment Coupon03Fragment;
    private String wsyNum ,ysyNum , ygqNum;
    @Override
    protected int getLayoutResId() {
        return R.layout.ui_yhj;
    }

    @Override
    protected void initView() {
        wsyNum = getIntent().getStringExtra("wsyNum");
        ysyNum = getIntent().getStringExtra("ysyNum");
        ygqNum = getIntent().getStringExtra("ygqNum");
        mTabLayout = (TabLayout) findViewById(R.id.destination_tab_layout);
        fragments = new ArrayList<>();
        fragments.add(Coupon01Fragment = (Coupon01Fragment) Fragment.instantiate(context,Coupon01Fragment.class.getName()));
        fragments.add(Coupon02Fragment = (Coupon02Fragment)Fragment.instantiate(context,Coupon02Fragment.class.getName()));
        fragments.add(Coupon03Fragment = (Coupon03Fragment)Fragment.instantiate(context,Coupon03Fragment.class.getName()));
        adapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.getTabAt(0).setText("未使用("+wsyNum+")");
        mTabLayout.getTabAt(1).setText("已使用("+ysyNum+")");
        mTabLayout.getTabAt(2).setText("已过期("+ygqNum+")");
    }

    private class MyFragmentPagerAdapter extends FragmentPagerAdapter {
        public MyFragmentPagerAdapter(FragmentManager fm) {
            super(fm);

        }
        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return fragments.size();
        }
    }

    public static void  choiceFragment(String num1, String num2, String num3){
        mTabLayout.getTabAt(0).setText("未使用("+num1+")");
        mTabLayout.getTabAt(1).setText("已使用("+num2+")");
        mTabLayout.getTabAt(2).setText("已过期("+num3+")");
    }


}
